// 导入二次封装axios
import koi from "@/utils/axios.ts";

// 统一管理接口
enum API {
  LIST_PAGE = "/blog/blogCatalog/listPage",
  LIST = "/blog/blogCatalog/list",
  CASCADER_LIST = "/blog/blogCatalog/cascaderList",
  GET_BY_ID = "/blog/blogCatalog/getById",
  ADD = "/blog/blogCatalog/add",
  UPDATE = "/blog/blogCatalog/update",
  DELETE = "/blog/blogCatalog/deleteById",
  BATCH_DELETE = "/blog/blogCatalog/batchDelete",
  UPDATE_STATUS = "/blog/blogCatalog/updateStatus",
  GET_SORTED = "/blog/blogCatalog/getSorted",
  UPDATE_IS_SPREAD = "/blog/blogCatalog/updateSpread",
  UPDATE_ARTICLE_ID = "/blog/blogCatalog/updateArticleId",
  BATCH_ADD = "/blog/blogCatalog/batchAddCatalog"
  
}

// 多条件分页查询
export const listPage = (params: any) => {
  return koi.get(API.LIST_PAGE, params);
};

// 列表查询
export const list = (params: any) => {
  return koi.get(API.LIST, params);
};

// 级联下拉框
export const cascaderList = (library: any) => {
  return koi.get(API.CASCADER_LIST + "/" + library);
};

// 根据ID进行查询
export const getById = (id: any) => {
  return koi.get(API.GET_BY_ID + "/" + id);
};

// 添加
export const add = (data: any) => {
  return koi.post(API.ADD, data);
};

// 根据ID进行修改
export const update = (data: any) => {
  return koi.post(API.UPDATE, data);
};

// 删除
export const deleteById = (id: any) => {
  return koi.post(API.DELETE + "/" + id);
};

// 批量删除
export const batchDelete = (ids: any) => {
  return koi.post(API.BATCH_DELETE, ids);
};

// 修改目录状态
export const updateStatus = (id: any, catalogStatus: any) => {
  return koi.post(API.UPDATE_STATUS + "/" + id + "/" + catalogStatus);
};

// 目录获取最新排序
export const getSorted = (catalogType: any, libraryId: any) => {
  return koi.get(API.GET_SORTED + "/" + catalogType + "/" + libraryId);
};

// 修改是否展开
export const updateSpread = (id: any, isSpread: any) => {
  return koi.post(API.UPDATE_IS_SPREAD + "/" + id + "/" + isSpread);
};

// 选择单个文章
export const updateArticleId = (id: any, articleId: any) => {
  return koi.post(API.UPDATE_ARTICLE_ID + "/" + id + "/" + articleId);
};

// 批量添加目录
export const batchAdd = (id: any, libraryId: any, data: any) => {
  return koi.post(API.BATCH_ADD + "/" + id + "/" + libraryId, data);
};

